package mpcs.utils
{
	
	/**
	 *  此类主要用来处理字符串的空格字符
	 * @author zhangzuoqiang
	 */	
	public class TrimUtils {
		
		public function TrimUtils() {
		}
		
		
		/**
		 *  清除子串左侧空格
		 * @param s
		 * @return 
		 */		
		public static function LTrim(s : String):String { 
			var i : Number = 0; 
			while(s.charCodeAt(i) == 32 || s.charCodeAt(i) == 13
				|| s.charCodeAt(i) == 10 || s.charCodeAt(i) == 9){ 
				i++; 
			}
			return s.substring(i,s.length);
		} 
		
		
		/**
		 *  清除字串右侧空格 
		 * @param s
		 * @return 
		 */		
		public static function RTrim(s : String):String {
			var i : Number = s.length - 1; 
			while(s.charCodeAt(i) == 32 || s.charCodeAt(i) == 13 || s.charCodeAt(i) == 10 ||s.charCodeAt(i) == 9) {
				i--;
			}
			return s.substring(0,i+1);
		}
		
		/**
		 *  清除字串左右的空格
		 * @param s
		 * @return 
		 */		
		public static function Trim(s : String):String {
			return LTrim(RTrim(s));
		} 
		
		
		
		
	}
}